/**
 * 
 */
package com.witframework.baseapp;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.witframework.PropertiesConstants;
import com.witframework.baseapp.security.Resource;
import com.witframework.baseapp.security.service.ResourceService;
import com.witframework.core.AppInitializer;
import com.witframework.core.ApplicationProperties;
import com.witframework.core.WitFrameWork;

/**
 * @author wuxinyang Jul 8, 2009 11:07:27 AM
 */

public class ResoueceInitializer implements AppInitializer {
	private static Log log = LogFactory.getLog(ResoueceInitializer.class);
	public void execute() {
		ResourceService resourceService=(ResourceService)WitFrameWork.getBean("resourceService");
		if (resourceService.getBy("resourceValue", "classpath:/com/witframework/webroot/framework/security/login.jsp") == null) {
			Resource r=new Resource();
			r.setName("登陆");
			r.setIsGuest("Y");
			r.setIsUse("Y");
			r.setIsNav("Y");
			r.setParentId("0");
			r.setResourceType("URI");
			r.setResourceValue("classpath:/com/witframework/webroot/framework/security/login.jsp");
			r.setIsPublic("N");
			r.setIsLocked("N");
			resourceService.save(r);
		}
		if (resourceService.getBy("resourceValue", "loginController"+ApplicationProperties.getProperty(PropertiesConstants.WIT)) == null) {
			Resource r=new Resource();
			r.setName("loginController");
			r.setIsGuest("Y");
			r.setIsUse("Y");
			r.setIsNav("N");
			r.setParentId("0");
			r.setResourceType("URI");
			r.setResourceValue("loginController"+ApplicationProperties.getProperty(PropertiesConstants.WIT));
			r.setIsPublic("N");
			r.setIsLocked("N");
			resourceService.save(r);
		}		
	}
	
}

    

